import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        token: localStorage.getItem('token') || '' ,// 从 localStorage 读取 token
        evaluationConfig: JSON.parse(localStorage.getItem("evaluationConfig")) || {
            measurementMetrics: [], // 评测指标 (存数字)
            transformMethod: [], // 变形方式 (存数字)
        },
        metricMapping: {
            "核心功能准确性": 1,
            "内容安全性评估": 2,
            "隐私保护合规性": 3,
            "公平性与包容性检测": 4,
            "信息真实性验证": 5,
            "响应效率与资源消耗": 6,
            "抗干扰稳定性测试": 7,
        },
    },
    mutations: {
        setToken(state, token) {
            state.token = token;
            localStorage.setItem('token', token); // 存入 localStorage
        },
        logout(state) {
            state.token = '';
            localStorage.removeItem('token');
        },
        setEvaluationConfig(state, config) {
            state.evaluationConfig = config;
            localStorage.setItem("evaluationConfig", JSON.stringify(config));
        },
    }
});
